package com.pig.elk.demo.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 这是那头猪？
 * @version 1.0
 * @description:
 * @date 2024/11/13 14:11
 */
@Slf4j
@RestController
public class DemoController {

    @GetMapping("/test")
    public String test() {
        log.info("这是一条info日志");
        log.error("这是一条error日志");
        return "测试日志";
    }

    @GetMapping("/error-test")
    public String errorTest() {
        try {
            throw new RuntimeException("测试异常");
        } catch (Exception e) {
            log.error("发生异常", e);
        }
        return "异常测试";
    }
}